/*
 * ListsProvider.java
 *
 * Created on February 21, 2007, 6:41 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package ge.info.domain;

import java.util.List;
import java.util.TreeMap;

/**
 *
 * @author Administrator
 */
public class ListsProvider
{
    
    /** Creates a new instance of ListsProvider */
    private DbExecutorIface dbExecutor;
    private TreeMap<Integer,Service> services;
    private TreeMap<Integer,ServiceDetail> serviceDetails;
    public ListsProvider()
    {
    }
    
    public DbExecutorIface getDbExecutor()
    {
        return dbExecutor;
    }
    
    public void setDbExecutor(DbExecutorIface dbExecutor)
    {
        this.dbExecutor = dbExecutor;
    }
    public TreeMap<Integer,Service> getServices()
    {
        if (services == null)
        {
            services = new TreeMap<Integer,Service>();
            List<Service> serviceList = getDbExecutor().getServices();
            for (Service service: serviceList)
            {
                services.put(service.getServiceID(),service);
            }
        }
        return services;
    }
    public TreeMap<Integer,ServiceDetail> getServiceDetails()
    {
        if (serviceDetails == null)
        {
            serviceDetails = new TreeMap<Integer,ServiceDetail>();
            List<ServiceDetail> serviceList = getDbExecutor().getAllServiceDetails();
            for (ServiceDetail detail: serviceList)
            {
                serviceDetails.put(detail.getDetailTypeID(),detail);
            }
        }
        return serviceDetails;
    }
    public String getServiceName(int id)
    {
        return getServices().get(id).getName();
    }
    public String getServiceDetailName(int id)
    {
        ServiceDetail sd = getServiceDetails().get(id);
        return sd.getDetailType();
    }
}
